import PropTypes from "prop-types"
import { queryList } from "../apis/user"
import CommonModalPicker from "./common/CommonModalPicker"

const UserPicker = ({
  onPick,
  disabled,
  disabledKeys = []
}) => {

  const columns = [
    {
      key: 'id',
      dataIndex: 'id',
      title: '用户id',
      width: 100,
    },
    {
      dataIndex: 'fullName',
      title: '名称',
      width: 200,
      searchKey: 'filter'
    },
    {
      key: 'email',
      dataIndex: 'email',
      title: '邮箱'
    },
    {
      key: 'tenantId',
      dataIndex: 'tenantId',
      title: '租户',
      width: 120
    },
  ]

  return <CommonModalPicker
    typeName="用户"
    queryAction={queryList}
    columns={columns}
    disabledKeys={disabledKeys}
    disabled={disabled}
    onPick={onPick}
    filters={[
      {
        type: 'search',
        name: 'filter',
        label: '名称'
      }
    ]}
  ></CommonModalPicker>
}

UserPicker.propTypes = {
  onPick: PropTypes.func,
  disabled: PropTypes.bool,
  disabledKeys: PropTypes.array
}

export default UserPicker